﻿#pragma once

#include "common.h"
#include "context.h"
#include "shape.h"
//#include "shader.h"
#include "ui/ui.h"
#include "ui/control_base.h"

namespace anip
{
	namespace ui
	{
		class Canvas : public Control
		{
		public:
			enum class FitType
			{
				Manual,
				Stretch,
				Rescale,
				Center,
				Tile // ANIP_FIXME: no longer supports tiling
			};

		private:
			//static Shader* shader;
			void fit();

		protected:
			void processScroll(invec2 pos) override;
			//void processParentResize() override;

		public:
			std::function<void(Canvas& self, invec2 pos)> onScroll;

			Canvas(Container* parent = nullptr, invec2 pos = { 0, 0 },
				invec2 size = { 100, 100 });

			// ANIP_TODO: update using resource.h

			vec2 scale = { 1, 1 };
			vec2 offset = { 0, 0 };
			color backColor = { 0, 0, 0, 0 };
			bool cutoff = true;
			bool flip = true;
			const Texture2D* texture;
			FitType fitType = FitType::Manual;

			void paint() override;
			void flow(Flow& f) override;
		};
	}
}